package net.zoneland.zrdp.biz.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import net.zoneland.zrdp.common.annotation.Log;
import net.zoneland.zrdp.common.core.controller.BaseController;
import net.zoneland.zrdp.common.core.domain.AjaxResult;
import net.zoneland.zrdp.common.enums.BusinessType;
import net.zoneland.zrdp.biz.domain.FlowApproveInfo;
import net.zoneland.zrdp.biz.service.IFlowApproveInfoService;
import net.zoneland.zrdp.common.utils.poi.ExcelProcessor;
import net.zoneland.zrdp.common.core.page.TableDataInfo;

/**
 * 审批记录Controller
 *
 * @author zonevue
 */
@RestController
@RequestMapping("/biz/flowApproveInfo")
public class FlowApproveInfoController extends BaseController {

    @Resource
    private IFlowApproveInfoService flowApproveInfoService;

    /**
     * 查询审批记录列表
     */
    @PreAuthorize("@ss.hasPermi('biz:flowApproveInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(final FlowApproveInfo flowApproveInfo) {
        startPage();
        final List<FlowApproveInfo> list = flowApproveInfoService.selectFlowApproveInfoList(flowApproveInfo);
        return getDataTable(list);
    }

    /**
     * 导出审批记录列表
     */
    @PreAuthorize("@ss.hasPermi('biz:flowApproveInfo:export')")
    @Log(title = "审批记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(final HttpServletResponse response, final FlowApproveInfo flowApproveInfo) {
        final List<FlowApproveInfo> list = flowApproveInfoService.selectFlowApproveInfoList(flowApproveInfo);
        final ExcelProcessor<FlowApproveInfo> util = new ExcelProcessor<>(FlowApproveInfo.class);
        util.exportExcel(response, list, "审批记录数据");
    }

    /**
     * 获取审批记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('biz:flowApproveInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") final Long id) {
        return success(flowApproveInfoService.selectFlowApproveInfoById(id));
    }

    /**
     * 新增审批记录
     */
    @PreAuthorize("@ss.hasPermi('biz:flowApproveInfo:add')")
    @Log(title = "审批记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody final FlowApproveInfo flowApproveInfo) {
        return toAjax(flowApproveInfoService.insertFlowApproveInfo(flowApproveInfo));
    }

    /**
     * 修改审批记录
     */
    @PreAuthorize("@ss.hasPermi('biz:flowApproveInfo:edit')")
    @Log(title = "审批记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody final FlowApproveInfo flowApproveInfo) {
        return toAjax(flowApproveInfoService.updateFlowApproveInfo(flowApproveInfo));
    }

    /**
     * 删除审批记录
     */
    @PreAuthorize("@ss.hasPermi('biz:flowApproveInfo:remove')")
    @Log(title = "审批记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable final Long[] ids) {
        return toAjax(flowApproveInfoService.deleteFlowApproveInfoByIds(ids));
    }
}
